package com.rdxer.service;

import com.rdxer.core.utils.IdWorker;
import com.rdxer.model.Department;
import com.rdxer.model.Notice;
import com.rdxer.repository.DepartmentRepository;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Department 服务层
 */
@Service
@Data
@Getter
public class DepartmentService implements CRUDPageServiceInterface<Department, String>  {


    @Autowired
    private DepartmentRepository repository;

    @Autowired
    private IdWorker idWorker;


    public Department add(Department model) {
        String id = getIdWorker().nextIdHex();
        model.setId(id);
        return getRepository().save(model);
    }
}
